
package ch.hearc.meteo.imp.afficheur.real.moo;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.RowSorter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;

public class MeteoTableCellRenderer extends DefaultTableCellRenderer
	{

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
		{
		MeteoTableModel model = (MeteoTableModel)table.getModel();
		Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		RowSorter<? extends TableModel> rowSorter = table.getRowSorter();
		if (rowSorter != null)
			{
			row = rowSorter.convertRowIndexToView(row);
			}
		c.setForeground(model.getRowColor(row));
		return c;
		}
	}
